<template>
  <FormulaEditor v-model="formula"></FormulaEditor>
  {{formulaVal}}=={{ val }}
</template>

<script setup>
import {computed, ref} from "vue";
import { $formulaUtils } from '@jzl/utils'

// const variables = $formulaUtils.parseVariables("${ IF( false, $$user.name, $user.nickname)}");
// console.log(Array.from(variables)); // 输出 ['a']

const formula = ref('${IF(a, b, c)}');

let formulaVal = $formulaUtils.formulaExec('你好，${ IF( false, $$user.name, user.nickname)}', { user: { name: '张三A', nickname: '张三B' } });

const val = computed(() => {
  return $formulaUtils.formulaExec(formula.value);
})

</script>

<style scoped>

</style>
